from django.db import models
from libs.db import BaseModel
from connection.models import Connection
from django_celery_beat.models import PeriodicTask


class ConnectionTask(BaseModel):
    connection = models.ForeignKey(Connection, related_name='connection_tasks', on_delete=models.CASCADE)
    periodic_task = models.ForeignKey(PeriodicTask, related_name='connection_tasks', on_delete=models.CASCADE)

    class Meta:
        verbose_name = '企业互联和定时任务的关联关系'
        verbose_name_plural = '企业互联和定时任务的关联关系'
        ordering = ('-id',)
        unique_together = [['connection', 'periodic_task']]
